#include "StdAfx.h"
#include "GalconCommonTypes.h"
#include "AbstractMessageFactory.h"
#include <boost/algorithm/string.hpp>
#include "FlightInfo.h"

AbstractMessageFactory::AbstractMessageFactory(void)
{
}


AbstractMessageFactory::~AbstractMessageFactory(void)
{
}

MessageBasePtr AbstractMessageFactory::ParseMessage( const Message& message)
{
   std::string messageStr(message.GetBody(), message.GetBodyLength());

   split_vector_type SplitVec; 
   boost::algorithm::split( SplitVec, messageStr, boost::algorithm::is_any_of(" "));

   MessageType mtype = static_cast<MessageType>(atoi(SplitVec[0].c_str()));
   MessagesEnum messageType = static_cast<MessagesEnum>(atoi(SplitVec[1].c_str()));

   split_vector_type_iter begin = SplitVec.begin() + 2;
   split_vector_type_iter end = SplitVec.end();
   
   return do_parseMessage(messageType, begin, end);
}